package com.gmall.data.utils;

import lombok.extern.slf4j.Slf4j;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * 各类外部链接创建工具类
 */
@Slf4j
public class ConnectionUtil {

    public static Connection getChConnection() {
        Connection conn = null;

        try {
            String ckDriver = "ru.yandex.clickhouse.ClickHouseDriver";
            String ckUrl = "jdbc:clickhouse://localhost:8123/default";
            String user = "default";
            String password = "123456";

            Class.forName(ckDriver);
            conn = DriverManager.getConnection(ckUrl, user, password);
        } catch (Exception e) {
            log.error("failed to getChConnection,error={}",e);
        }
        return conn;
    }

}
